<?php

	/**
	 * @package Yomm
	 * @author bsuter
	 *
	 */
	Class Yomm_Library_CmsPageParserFilters {
		
		public function href($text_to, $filter_atribute)
		{
			return '<a href="' . $filter_atribute . '" title="' . $text_to . '">' . $text_to . '</a>';
		}

		public function href_blank($text_to, $filter_atribute)
		{
			return '<a target="_blank" href="' . $filter_atribute . '" title="' . $text_to . '">' . $text_to . '</a>';
		}
		
		public function mail($text_to, $filter_atribute)
		{
			return '<a href="javascript:baseApp.mailer(\''.base64_encode('mailto:' . $filter_atribute).'\');">'. $text_to . '</a>';
		}
		
		/**
		 * @param $text_to [char] youtube url (www.youtube.com/watch?v=nQjhaJwvkDk)
		 * @param $filter_atribute [char] width atribute (200)
		 */
		public function youtube($text_to, $filter_atribute = 480)
		{
			$width = $filter_atribute; // und nun 80,2 prozent davon berechenen gibt die breite
			
			$height = round(($width/100) * 80.2);
			
			$data = str_replace("watch?v=","v/", $text_to);
			
			return '<div class="yt_video">
				<object type="application/x-shockwave-flash" style="width:'.$width.'px; height:'.$height.'px;" data="'.$data.'">
				<param name="movie" value="'.$data.'" />
				<param name="allowFullScreen" value="true" />
				</object>
				</div>
			';
			
			/*
			 * XX SOURCE:
			 * 	<object type="application/x-shockwave-flash" style="width:450px; height:366px;" data="http://www.youtube.com/v/nQjhaJwvkDk">
			 *	<param name="movie" value="http://www.youtube.com/v/nQjhaJwvkDk" />
			 *	</object><div style="font-size: 0.8em"><a href="http://www.tools4noobs.com/online_tools/youtube_xhtml/">Get your own valid XHTML YouTube embed code</a></div>
			 */
			
			/*
			 * YOUTUBE SOURCE:
			 * <object width="480" height="385"><param name="movie" value="http://www.youtube.com/v/nQjhaJwvkDk&hl=de_DE&fs=1&color1=0xe1600f&color2=0xfebd01"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/nQjhaJwvkDk&hl=de_DE&fs=1&color1=0xe1600f&color2=0xfebd01" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed></object>
			 * 
			 */
		}
		
		/**
		 * returns the link for an internal page - if found (TODO: verify if the link was found
		 * 
		 * @param $text_to [char] the text which will be wrapped (ex. 'click here')
		 * @param $filter_atribute [char] the rewrite name (ex. 'home')
		 */
		public function href_intern($text_to, $filter_atribute)
		{
			return '<a href="' . Tools::BuildLinkByRewrite($filter_atribute) . '" title="' . $text_to . '">' . $text_to . '</a>';
		}
		
	}